<template>
    <div>
        <div class="herd">
            <p class="title">个人中心</p>
            <div class="user">
                <van-image width="70" height="70" round v-if="accountStore.account.url" :src="'http://localhost:3000/test/pic?img='+accountStore.account.url" />
                <van-image width="70" height="70" round v-else src="https:fastly.jsdelivr.net/npm/@vant/assets/ipad.jpeg" />  
                <span v-if="mesg">{{mesg}}</span>
                <router-link v-else class="bname" to="/login">请登录账号</router-link>
                <van-tag plain type="danger">积分3960</van-tag>
                <!-- <p class="user-change">账号管理<van-icon name="replay" />
                    <ul>
                        <li @click="getOl">切换用户</li>
                        <li @click="getOut">退出登陆</li>
                    </ul>
                </p> -->
                <van-collapse v-model="activeNames">
                    <van-collapse-item title="账号管理" >
                        <van-button @click="getOut">退出登录</van-button>
                    </van-collapse-item>
                </van-collapse>
            </div>
            <p class="black"><span>会员</span>升级会员享更多优惠 <van-overlay :show="vx" @click="vx = false">
                    <div class="wrapper" @click.stop>
                        <div class="block"><img src="../../img/微信图片_20230207194850.jpg" alt=""></div>
                    </div>
                </van-overlay>
                <van-button type="primary" text="详情" @click="vx = true" />
                <van-overlay :show="vx" @click="vx = false" />
            </p>
        </div>
        <!-- 订单导航 -->
        <div class="herdtoo">
            <div><router-link :to="{ path: '/oders', query: { msg: '0' } }"><van-icon name="shop-collect-o"
                        color="#FA4F51" size="58"></van-icon></router-link><span>全部订单</span></div>
            <div><router-link :to="{ path: '/unpaid', query: { msg: '1' } }"><van-icon name="question-o" color="#FA4F51"
                        size="58"></van-icon></router-link><span>已交易</span></div>
            <div><router-link :to="{ path: '/paid', query: { msg: '2' } }"><van-icon name="info-o" color="#FA4F51"
                        size="58"></van-icon></router-link><span>待提货</span></div>
            <div><router-link :to="{ path: '/pickedup', query: { msg: '3' } }"><van-icon name="passed" color="#FA4F51"
                        size="58"></van-icon></router-link><span>已提货</span></div>
        </div>
        <!-- 地址确认 -->
        <div class="address">
            <p class="p1">我的当前地址<span @click="edit">成都市郫都区中信大道二段1号</span></p>
            <!-- <p class="p2">{{address}}</p> -->
            <van-icon name="friends-o" color="#FA4F51"></van-icon><span>2.8万人来过</span>
            <van-icon name="thumb-circle-o" color="#FA4F51"></van-icon><span>17.3万点赞</span>
            <!-- <p class="p3">门店地址: <span>成都市锦江区春熙路243号</span></p> -->
            <div class="phone">
                <div class="div1">
                    <van-cell is-link title="联系门店" @click="show = true" />
                    <van-action-sheet v-model:show="show" :actions="actions" @select="onSelect" cancel-text="取消"
                        description="18111296897" @cancel="onCancel" />
                </div>
                <div class="div2">
                    <van-cell is-link title="导航到店"  @click="tomap"/>
                </div>
            </div>
            <!-- 温馨提示 -->
            <div class="van-notice-bar">
                <div class="icon">
                    <van-icon name="wechat-pay" color="green" size="24"></van-icon>
                </div>
                <p>如果您购买的商品有任何问题,请直接与购买门店联系,门店会为您处理,让您售后无忧！</p>
            </div>
        </div>
        <div class="goshoping">
            <router-link to="/home"><van-button type="danger" block round><span>去购物</span></van-button></router-link>
        </div>
    </div>
</template>

<script  lang="ts" setup>
import { ref } from 'vue'
import { Toast } from 'vant'
import { useRouter } from 'vue-router'
import { useAccountStore } from '@/stores/user';
const accountStore = useAccountStore()
const mesg = ref(accountStore.account.nick)
// 账号管理数据
const activeNames = ref(['1']);
// 地址信息
const address = ref('四川省成都市郫都区中信大道二段1号')
// 弹出微信
const vx = ref(false)
// 弹出电话框
const show = ref(false);
const actions = [{ name: '呼叫' },];
// 弹出电话方法
const onSelect = (item: any) => {
    show.value = false;
    Toast(item.name);
}
// 导航到店
const tomap =()=>{
    router.push({path:'/map'})
}
// 取消操作方法
const onCancel = () => Toast('取消')
// 修改地址
const edit = ()=>{
    address.value = '四川省成都市郫都区中信大道二段1号'
}

//退出登录
const router = useRouter()
const getOut = () =>{ 
    accountStore.deleteAccount()
    localStorage.removeItem('TOKEN')
    Toast.success('退出成功！')
    router.replace('/home')
}


</script>

<style lang="scss" scoped>

.van-button:before{
    height: 54%;
}
.herd {
    width: 100%;
    padding-top: 2%;
    background-color: #EC0D0D;
    border-bottom-left-radius: 64px;
    border-bottom-right-radius: 64px;
    .van-collapse{
        height: 30px;
        float: right;
        --van-collapse-item-content-background-color:#EC0D0D;
        :deep(.van-cell--clickable) {
            background-color: #EC0D0D;
            height: 30px;
            color: white;
        }
        :deep(.van-collapse-item__content){
            padding: 0;
            margin-left: 30px;
            font-size: 8px;
            height: 30px;
        }
        .van-button{
            background-color: #EC0D0D;
            border: none;
            color: white;
        }
    }
    .user {
        margin-bottom: 10px;
        margin-left: 3%;
        margin-right: 3%;
        position: relative;

        span {
            position: absolute;
            margin-left: 6%;
            font-size: 14px;
            color: white;
        }
        .bname{
            position: absolute;
            color: #fff;
            font-size:20px;
        }

        .van-tag {
            margin-left: 6%;
            margin-top: 9%;
            font-size: 12px;
            color: black;
            font-weight: 600;
            padding: 0.8%;
            border-radius: 5px;
            opacity: 0.5;
        }

        .user-change {
            float: right;
            color: white;
            font-size: 12px;
            margin-top: 5%;
        }

        .user-change ul {
            margin-left: 8px;
            cursor: pointer;
            display: none;
        }

        .user-change:hover ul {
            display: block;
        }
    }

    .title {
        padding-bottom: 2%;
        color: white;
        text-align: center;
        font-size: 16px;
        font-weight: 600;
    }

    .menu {
        float: right;
    }

    .black {
        padding-top: 4%;
        background-color: black;
        width: 320px;
        height: 30px;
        margin: 0 auto;
        border-radius: 10px;
        border-bottom-left-radius: 30px;
        border-bottom-right-radius: 30px;
        color: #9F9492;
        text-align: 40px;
        position: relative;
        font-size: 12px;
        .wrapper {
                display: flex;
                align-items: center;
                justify-content: center;
                height: 100%;
            }

            .block {
                width: 54%;
                height: 40%;
                background-color: #fff;

                img {
                    width: 100%;
                    height: 100%;
                }
            }

        span {
            margin-left: 10%;
            margin-right: 10%;
            color: #E3A947;
            font-size: 12px;
        }

        .van-button {
            position: absolute;
            margin-left: 10%;
            width: 58px;
            height: 18px;
            border-radius: 10px;
            color: #85580b;
            background-color: #FCD3AF;
            border: none;
        }
    }
}

.herdtoo {
    width: 100%;
    height: 92px;
    border-bottom-left-radius: 7px;
    border-bottom-right-radius: 7px;
    box-shadow: 0px 3px 2px 0px rgba(214, 214, 214, 0.5);
    display: flex;
    justify-content: space-around;

    div {
        margin-top: 10px;
        width: 50px;
        height: 60px;
        cursor: pointer;
    }

    span {
        font-size: 12px;
        font-weight: 600;
        text-align: center;
        margin-left: 2px;
        padding-top: 1px;
    }
}

.address {
    width: 100%;
    border-radius: 2px;
    box-shadow: 0px 3px 2px 0px rgba(208, 208, 208, 0.5);
    border-bottom-left-radius: 7px;
    border-bottom-right-radius: 7px;
    margin: 1%;
    position: relative;

    .p1 {
        padding-left: 6%;
        margin-top: 2%;
        padding-top: 3%;
        width: 93%;
        height: 30px;
        background-color: #E6D48C;
        color: #917810;
        font-weight: 600;
        font-size: 12px;

        span {
            margin-left: 24%;
            color: #363326;
        }
    }

    img {
        position: absolute;
        top: 16.3%;
        left: 18%;
    }

    .p2 {
        margin-top: 1%;
        margin-left: 7%;
        font-size: 12px;
        font-weight: 600;
    }

    .van-icon {
        margin-left: 3%;
    }

    span {
        font-size: 12px;
    }

    .p3 {
        margin-left: 5%;
    }

    .phone {
        margin-left: 1%;
        margin-bottom: -1%;
        width: 100%;
        display: flex;
        justify-content: space-around;

        .div1 {
            width: 29%;
            height: 15%;
            padding-top: 1%;
            padding-left: 3%;
            border: solid 2px black;
            text-align: center;

            .van-cell {
                height: 80%;
                margin-top: -2%;
            }
        }

        .div1:hover {
            border: solid 2px red;
            color: red;
        }

        .div2 {
            width: 29%;
            height: 15%;
            padding-top: 1%;
            padding-left: 3%;
            border: solid 2px black;
            text-align: center;

            .van-cell {
                height: 80%;
                margin-top: -2%;
            }
        }

        .div2:hover {
            border: solid 2px red;
            color: red;
        }
    }
}

.van-notice-bar {
    background-color: #FED8D9;
    color: #040709;
    border-radius: 8px;
    width: 99%;
    height: 30%;

    .icon {
        float: left;
        margin-top: 15px;
        margin-left: 5px;
    }

    p {
        padding-top: 2%;
        margin: 3% 2%;
        line-height: 20px;
        text-align: center;
        font-size: 12px;
    }
}

.goshoping {
    margin: 0 auto;
    width: 50%;
    height: 6%;

    span {
        font-size: 12px;
    }
}
</style>